<%@ page pageEncoding="UTF-8"%>
<%@ include file="../common/head.jsp"%>
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<%@ include file="./msg/meta.jsp"%>
</head>
<body>
	<div class="layui-fluid">
		<div class="layui-row">
			<form action="${ctx}/sys/update${actionclass}.do" method="post" class="layui-form" style="margin-top: 10px"
				id="dataform">
				<input type="hidden" value="${modifybean.id}" name="id" />
				<div class="layui-form-item">
					<label class="layui-form-label">头像</label>
					<div class="layui-input-block">
						<div class="layui-upload-drag" id="file_photo">
							<i class="layui-icon"></i>
							<p>点击上传，或将文件拖拽到此处</p>
							<div class="" id="view_photo">
								<img src="${ctx}/resource/${modifybean.photo}" alt="请上传文件" style="max-width: 196px"
									onerror="javascript:this.src='${ctx}/resource/no-small.jpg'">
							</div>
							<input type="text" value="${modifybean.photo}" name="photo" id="text_photo" readonly="readonly"
								style="width: 100%; border: none;" />
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">账号</label>
					<div class="layui-input-block">
						<input type="text" name="uname" id="SimpleUser_uname" value="${modifybean.uname}" lay-verify="required"
							lay-reqtext="请输入账号" placeholder="" autocomplete="off" class="layui-input" readonly="readonly">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">密码</label>
					<div class="layui-input-block">
						<input type="password" name="userPassword" id="SimpleUser_userPassword" value="" lay-verify="" lay-reqtext="请输入密码"
							placeholder="" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">确认密码</label>
					<div class="layui-input-block">
						<input type="password" name="userPassword1" id="SimpleUser_userPassword1" value="" lay-verify="confirmPass"
							lay-reqtext="请输入确认密码" placeholder="" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">姓名</label>
					<div class="layui-input-block">
						<input type="text" name="userName" id="SimpleUser_userName" value="${modifybean.userName}" lay-verify="required"
							lay-reqtext="请输入姓名" placeholder="" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">性别</label>
					<div class="layui-input-block">
						<select name="userGender" id="SimpleUser_userGender">
							<option value="男">男</option>
							<option value="女">女</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">联系电话</label>
					<div class="layui-input-block">
						<input type="text" name="userPhone" id="SimpleUser_userPhone" value="${modifybean.userPhone}"
							lay-verify="required|phone" lay-reqtext="请输入联系电话" placeholder="" autocomplete="off" class="layui-input"
							maxlength="11">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">邮箱</label>
					<div class="layui-input-block">
						<input type="text" name="userEmail" id="SimpleUser_userEmail" value="${modifybean.userEmail}"
							lay-verify="required|email" lay-reqtext="请输入邮箱" placeholder="" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">出生日期</label>
					<div class="layui-input-block">
						<input type="text" name="userBirth" id="SimpleUser_userBirth" value="${modifybean.userBirth}" lay-verify=""
							lay-reqtext="请输入出生日期" placeholder="" autocomplete="off" class="layui-input" readonly="readonly">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">联系地址</label>
					<div class="layui-input-block">
						<input type="text" name="userAddress" id="SimpleUser_userAddress" value="${modifybean.userAddress}" lay-verify=""
							lay-reqtext="请输入联系地址" placeholder="" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button type="submit" class="layui-btn" lay-submit="" lay-filter="sysgo">保存</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</body>
<script>
	$("#SimpleUser_userGender").val("${modifybean.userGender}");
	layui.use([ 'laydate', 'form' ], function() {
		var laydate = layui.laydate;
		var form = layui.form;
		form.verify({
			confirmPass : function(value) {
				if ($('input[name=userPassword]').val() !== value)
					return '两次密码输入不一致！';
			}
		});
		form.on('submit(sysgo)', function(data) {
			console.log(data.form.action);
			$.ajax({
				type : 'POST',
				url : data.form.action,
				dataType : 'json',
				data : data.field,
				success : function(data) {
					if (data.statusCode == 200) {
						layer.msg(data.message, {
							icon : 1,
							time : 1000
						}, function() {
							var index = parent.layer.getFrameIndex(window.name);
							parent.location.replace(parent.location.href)
							parent.layer.close(index);

						});
					} else {
						layer.msg(data.message, {
							icon : 2,
						});
					}
				},
				error : function(data) {
					console.log(data);
				},
			});
			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		});
		//执行一个laydate实例
		laydate.render({
			elem : '#SimpleUser_userBirth' //指定元素
		});
	});
	$(function() {
		layui.use('upload', function() {
			var $ = layui.jquery,
				upload = layui.upload;
			//普通图片上传
			upload.render({
				elem : '#file_photo',
				url : '${ctx}/com/fileUpload.do', //改成您自己的上传接口
				accept : "images", //images（图片）、file（所有文件）、video（视频）、audio（音频）
				done : function(res) {
					console.log(this.accept);
					layer.msg('上传成功');
					if (this.accept == 'images') {
						layui.$('#view_photo').removeClass('layui-hide').find('img').attr('src', '${ctx}/resource/' + res.filename);
					}
					$("#text_photo").val(res.filename);
					$("#photo").val(res.filename);
				//console.log($(this)[0].accept)
				}
			});
		});
	});
</script>
</html>
<%@ include file="../common/clear.jsp"%>